
ifeq ($(gcc),1)
   CC=gcc 
else
   TOOLCHAIN=../../buildroot/output/host
   #RASPBERRY
   #CC=$(TOOLCHAIN)/usr/bin/i486-unknown-linux-uclibc-gcc
   CC=$(TOOLCHAIN)/usr/bin/arm-unknown-linux-uclibcgnueabi-gcc

endif



OPTS= -Wall -std=gnu99 -pedantic -O2 -s
HDRS= -I $(TOOLCHAIN)/usr/include -I src/ -I ../opendomo-common/libraries -I ../opendomo-ai/src/  #-I libconfig/ 
LIBS= -lssl -lcrypto -lcrypt -lconfig -ljpeg -lm




# -- default ------------------------------------------------------------------
default: odcgi


# -- libconfig ----------------------------------------------------------------
#LIBCONFIG_FILES = libconfig/grammar.c libconfig/scanner.c libconfig/libconfig.c


# -- odcgi --------------------------------------------------------------------
ODCM_FILES = ../opendomo-common/libraries/coelacanth/str.c ../opendomo-common/libraries/coelacanth/string.c ../opendomo-common/libraries/regex/match.c ../opendomo-common/libraries/crypto/base64.c ../opendomo-common/libraries/ai/perceiving/vision/jpeg.c  ../opendomo-common/libraries/ai/perceiving/vision/image.c ../opendomo-common/libraries/ai/perceiving/vision/mjpg.c
ODCGI_OBJS = src/mjpg.o src/i18n.o src/user.o src/file.o src/util.o src/session.o src/cgi.o src/secfunc.o src/script.o
                
odcgi: $(ODCGI_OBJS) 
	$(CC) $(OPTS) $(HDRS)  $(ODCM_FILES) $(ODCGI_OBJS) $(LIBCONFIG_FILES) src/odcgi.c -o var/www/cgi-bin/od.cgi -g $(LIBS)
	#$(CC) $(OPTS) $(HDRS) src/secfunc.o src/user.o  src/test.c -o bin/test -l crypt



# -- standard object ----------------------------------------------------------
%.o: %.c %.h
	$(CC) $(OPTS) $(HDRS) -c $< -o $@


install:
	cp -f bin/* /usr/lib/cgi-bin/
	cp -fr html/* /var/www/
	rm -fr /etc/opendomo/root && cp -fr conf/* /etc/opendomo/

clean:
	rm -f bin/*
	rm -f */*.o 
	rm -fr pkg/o*.tar.gz




